<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="java.util.List" %>
<%@ page import="org.test.once.model.Role"%>
<%@ page import="org.test.once.model.*" %>
<%
	request.setCharacterEncoding("GB2312");
	List<Role> roles = (List<Role>)request.getAttribute("roles");
	User roleuser = (User)request.getAttribute("roleuser");
	//int nameid = roleuser.getId
	//request.setAttribute("setrole", rolename);
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    
    <title>角色信息</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<link href="../style/oa.css" rel="stylesheet" type="text/css">
<script type="text/javascript" language="javascript">

function modifyUser(){
	//alert("ok");
		var selectFlags = document.getElementsByName("selectFlag");
		var count = 0;
		var j = -1;
		for(var i = 0; i < selectFlags.length; i++) {
			if(selectFlags[i].checked) {
				j = i;
				count++;
				//alert(j);
			}
		}
		if(count <= 0) {
			alert("请选中要设置的权限");
			return;
		}
		
		if(count > 1) {
			alert("一次只能设置一个权限!!!");
			return;
		}
		window.location.href = "UserServlet?role_id=" + selectFlags[j].value + "&command=modifyUser" + "&userid=" + "<%=roleuser.getId()%>";
	}
	
	function shouquan1() {
		//alert("ok");
	}
	
	function checkAll() {
		var selectFlags = document.getElementsByName("selectFlag");
		for(var i = 0; i < selectFlags.length; i++) {
			selectFlags[i].checked = document.getElementById("ifAll").checked;
		}
		
	}
</script>
  </head>
  
  <body>
  <BODY bgColor=#dee7ff leftMargin=0 background="" topMargin=0 marginheight="0" marginwidth="0" style="overflow: hidden;">
<form name="userform" id="userform">
<center>

      <TABLE width="100%" border=0 align=center cellPadding=0 cellSpacing=0 borderColor=#ffffff style="FONT-SIZE: 10pt">
        <TBODY>
          <TR>
            <TD width="82%" height=14 align=right vAlign=center noWrap>
            </TD>
            <TD width="18%" align=right vAlign=center noWrap>　</TD>
          </TR>
          <TR>
            <TD height=14 align=right vAlign=center noWrap>
            	<!-- 在这里插入查询表单 -->
            </TD>
            <TD height=14 align="left" vAlign=center noWrap>
            </TD>
          </TR>
          <TR>
            <TD height=28 colspan="1" align=right vAlign=center noWrap background=images/list_middle.jpg style="width: 1000px; ">
            
            </TD>
          </TR>
        </TBODY>
      </TABLE>
      给用户"<%=roleuser.getUserName() %>"设置权限<hr>
      <table width="100%" border="0" cellPadding="0" cellSpacing="1" bgcolor="#6386d6">
          <!-- 列表标题栏 -->
	      <tr bgcolor="#EFF3F7" class="TableBody1">
	      	  <td  width="5%" height="37" align="center"><input type="checkbox" name="ifAll"onclick="checkAll()"/></td>
		      <td width="45%" height="37" align="center"><b>序号</b></td>
		      <td width="50%" height="37" align="center"><B>姓名</B></td>
		      
          </tr>
          <!-- 列表数据栏 -->
          
          <%if(!roles.isEmpty()) {%>
          <%for(Role role : roles)  {%>
	      <tr bgcolor="#EFF3F7" class="TableBody1" onmouseover="this.bgColor = '#DEE7FF';" onmouseout="this.bgColor='#EFF3F7';">
	      	  <td align="center" vAlign="center"><input type="checkbox" name="selectFlag" id="selectFlag" value="<%=role.getId()%>" onclick="shouquan1()"/></td>
		      <td align="center" vAlign="center"><%=role.getId() %></td>
	          <td align="center" vAlign="center"><%=role.getName() %></td>
        	</tr>
        <%} %>
		<%} %>
		
        <!-- 在列表数据为空的时候，要显示的提示信息 -->
	    <%if(roles.isEmpty()) {%>
	    <tr>
	    	<td colspan="7" align="center" bgcolor="#EFF3F7" class="TableBody1" onmouseover="this.bgColor = '#DEE7FF';" onmouseout="this.bgColor='#EFF3F7';">
	    	没有找到相应的记录
	    	</td>
	    </tr>
	    <%} %>
	    
      </table>

</center>
<div align="center">
<br><br>
<input  type="button" name="shouquan" value="授权" onclick="modifyUser()">
</div>
    </form>
  </body>
</html>
